<?php

namespace App\Console\Commands;

use App\model\Workshop;
use App\Repository\WorkShopRepository;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;

class QiniuSliderCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'qiniu:slider';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';
    protected  $workShopRepository;
    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct(WorkShopRepository $workShopRepository)
    {
        $this->workShopRepository=$workShopRepository;
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Workshop::chunk(100,function($workshop){
            foreach ($workshop as $item){
               $this->workShopRepository::setSlider($item);
               $this->info($item->id);
            }
        });
    }
}
